package com.dyzx.hbb.modules.wms.controller;


import com.dyzx.hbb.common.config.MyLambdaQueryWrapper;
import com.dyzx.hbb.common.controller.BaseValidController;
import com.dyzx.hbb.modules.wms.entity.WmsInventory;
import com.dyzx.hbb.modules.wms.query.WmsInventoryQuery;
import com.dyzx.hbb.modules.wms.service.WmsInventoryService;
import com.dyzx.hbb.modules.wms.vo.WmsInventoryVO;
import com.dyzx.hbb.modules.wms.vo.WmsInventoryUVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 库存管理控制器
 * <p>处理仓库管理系统中库存信息的查询和管理业务逻辑
 * <p>主要职责：
 * <ul>
 * <li>提供库存信息的基础查询功能</li>
 * <li>支持按产品、仓库、货位等条件筛选库存数据</li>
 * <li>维护库存状态管理</li>
 * <li>实现库存数据的排序展示</li>
 * </ul>
 * <p>设计意图：为仓库管理模块提供统一的库存数据访问接口，
 * 确保库存信息的实时性和准确性，支持库存状态的有效跟踪
 * 
 * @author 开发团队
 * @version 1.0.0
 * @since 2023-05-30
 */
@Tag(name = "库存管理", description = "库存相关接口")
@RestController
@RequestMapping("/wms/inventory")
public class WmsInventoryController extends BaseValidController<
        WmsInventoryService,
        WmsInventory,
        WmsInventoryQuery,
        WmsInventoryVO,
        WmsInventoryUVO
        > {

    @Autowired
    private WmsInventoryService service;

    @Override
    protected WmsInventoryService getBaseService() {
        return service;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsInventory> queryWrapper(WmsInventoryQuery query) {
        MyLambdaQueryWrapper<WmsInventory> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsInventory::getCreateDate);

        if (query != null) {
            queryWrapper.eq(query.getProduct_id() != null, WmsInventory::getProductId, query.getProduct_id())
                    .eq(query.getHouse_id() != null, WmsInventory::getHouseId, query.getHouse_id())
                    .eq(query.getLocation_id() != null, WmsInventory::getLocationId, query.getLocation_id())
                    .eq(query.getStatus() != null, WmsInventory::getStatus, query.getStatus());
        }
        return queryWrapper;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsInventory> queryInfoWrapper() {
        MyLambdaQueryWrapper<WmsInventory> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsInventory::getCreateDate);
        return queryWrapper;
    }

    @Override
    protected WmsInventory addValid(WmsInventoryVO entity) {
        return null;
    }

    @Override
    protected WmsInventory editValid(WmsInventoryUVO entity) {
        return null;
    }
}